<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>生日提醒页面</title>
<meta name="renderer" content="webkit">	
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
<meta name="apple-mobile-web-app-status-bar-style" content="black">	
<meta name="apple-mobile-web-app-capable" content="yes">	
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/table.css">
</head>
<body>
	<div class="content-head">悦宝园会员管理系统</div>
	<div class="content-main">
		<div class="side-nav" ms-controller="navBar">
			<ul class="nav-item">
				<li><a href="main.html" class="nav-item-front nav-item-add">首页</a></li>
				<li ms-for="el in @navTitleArr">
					<a href="javascript:;" class="nav-item-front">{{el.par}}</a>
					<dl class="nav-item-child">
						<dd ms-for="($index, ex) in el.child"><a ms-attr='{href: el.href[$index]}'>{{ex}}</a></dd>
					</dl>
				</li>
			</ul>
		</div>
		<div class="content bg-gray" ms-controller="main">
			<div class="tab-content">
				<div class="tab-item">
					<div class="sub-main">
						<p class="sub-title"><i>生日提醒</i></p>
						<div class="table-area">
							<div class="table-head">
								<span class="col-30">宝宝姓名</span>
								<span class="col-70">出生日期</span>
							</div>
							<div class="table-body">
								<div class="table-line" ms-for="el in @dataArr()">
									<div class="col-padding col-border col-inline col-center col-30">{{el.name}}</div>
									<div class="col-padding col-border col-inline col-center col-70" ms-html="@birthday(el.birthday)"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<script src="js/jq.js"></script>
<script src="js/avalon.js"></script>
<script src="js/main.js"></script>
<script>
(function() {

	var vm = avalon.define({
		$id: "main",
		birthday: function(birthday) {
			var now = new Date();
			var birthday = birthday.split("-");
			var flagDate = [now.getFullYear(),birthday[1], birthday[2]].join("-");
			var time = now.getFullYear() + "-" +((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1)+"-"+(now.getDate()<10?"0":"")+now.getDate();

			var diffDate = baseFunc.dateDiff(flagDate, time);

			if(diffDate == 0) {
				return "<span>"+birthday.join("-")+"<i class='birthday-today'>今日</i></span>";
			}

			if(diffDate < 0 && diffDate > -5) {
				return "<span>"+birthday.join("-")+"</span>";
			}
		},
		dataArr: function() {
			var allData = baseFunc.getStorageData("member");
			var values = Object.values(allData);
			var now = new Date();
			var resArr = [];
			var birthArr = [];
			var time = now.getFullYear() + "-" +((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1)+"-"+(now.getDate()<10?"0":"")+now.getDate();

			birthArr = time.split("-");

			for(var i = 0; i < values.length; i++) {
				var birthday = values[i].birthday.split("-");
				var flagDate = [now.getFullYear(),birthday[1], birthday[2]].join("-");

				var diffDate = baseFunc.dateDiff(flagDate, time);

				if(diffDate <= 0 && diffDate > -5) {
					resArr.push(values[i]);
				}
			}
			return resArr;
		}
	});
})();
</script>
</body>
</html>